from django.urls import path, include
from django.views.generic import TemplateView

from . import views

app_name = 'blog'
urlpatterns = [
    # 文章
    path('', views.PostListView.as_view(), name='index'),
    path('post/', include([
        path('new/', views.PostCreateView.as_view(), name='create'),
        path('<slug:slug>/likes/', views.PostLikeView.as_view(), name='like'),
        path('user/<str:username>/', views.UserPostListView.as_view(), name='user_posts'),
        path('<slug:slug>/', views.PostDetailView.as_view(), name='detail'),
        path('<slug:slug>/edit/', views.PostUpdateView.as_view(), name='update'),
        path('<slug:slug>/delete/', views.PostDeleteView.as_view(), name='delete'),
    ])),

    # 栏目（类别）
    path('category/', include([
        path('new/', views.CategoryCreateView.as_view(), name='new_category'),
        path('<str:category_name>/', views.CategoryPostListView.as_view(), name='category_posts'),
        path('<str:date>/posts/', views.ArchivePostListView.as_view(), name='month_archive'),
    ])),

    # 标签
    path('tag/new/', views.TagsCreateView.as_view(), name='new_tags'),
]
